# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Carlo Landmeter <clandmeter@alpinelinux.org>
pkgname=py3-reportlab
_pyname=reportlab
pkgver=3.6.13
pkgrel=2
pkgdesc="Python library for generating PDFs and graphics"
url="https://www.reportlab.com/opensource"
arch="all"
license="BSD-3-Clause"
depends="py3-pillow python3 font-dejavu"
makedepends="
	freetype-dev
	libart-lgpl-dev
	py3-gpep517
	py3-setuptools
	py3-wheel
	python3-dev
	"
subpackages="$pkgname-pyc"
source="https://files.pythonhosted.org/packages/source/${_pyname:0:1}/$_pyname/$_pyname-$pkgver.tar.gz"
builddir="$srcdir/$_pyname-$pkgver"

replaces="py-reportlab" # Backwards compatibility
provides="py-reportlab=$pkgver-r$pkgrel" # Backwards compatibility

prepare() {
	default_prepare

	# use installed (system) libart
	rm -rf src/rl_addons/renderPM/libart_lgpl

	# remove interpreter line from libraries
	find src -type f -name "*.py" -exec sed -i '/^#!\//d' {} \;
}

build() {
	export CFLAGS="$CFLAGS -I/usr/include/libart-2.0"

	gpep517 build-wheel \
		--wheel-dir .dist \
		--config-json '{"--build-option": ["--use-system-libart"]}' \
		--output-fd 3 3>&1 >&2
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
059c3acf2c995ebdd3ffe005bd98640bc9c063c2fb9b3115351b9c1a4f7cfdabf4ffe61123342de2e84773005d46cf6d44410042206222df0700259e31ec7aae  reportlab-3.6.13.tar.gz
"
